.\" generated with Ronn-NG/v0.9.1
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
.TH "LIBCONFINI" "3" "July 2022" "Stefano Gioffré" "Library Functions Manual"
.SH "NAME"
\fBlibconfini\fR
.SH "DESCRIPTION"
\fBlibconfini\fR is a simple INI parsing library with the ability to read disabled entries (i\.e\. valid entries nested in comments)\. \fBlibconfini\fR does not store the data read from an INI file, but rather dispatches it, formatted, to a custom listener\.
.P
The code is written in C (C99) and does not depend on any particular library, except for the C standard headers \fBstdio\.h\fR, \fBstdlib\.h\fR, \fBstdbool\.h\fR and \fBstdint\.h\fR\.
.P
If you want to start learning directly from the code, you can find partially self\-documented sample usages of \fBlibconfini\fR under \fB/usr/share/doc/libconfini/examples\fR\.
.SH "WHAT IS AN INI FILE?"
INI files were introduced with the early versions of \fBMicrosoft Windows\fR, where the \fB\.ini\fR file name extension stood for INItialization\. An INI file can be considered as a string representation of a tree object, with new lines used as delimiters between nodes\. A typical INI file is a plain text file looking like the following example:
.IP "" 4
.nf
# delivery\.conf

; general options

location = Colosseum
place = Rome

[sender]
name = John Smith
email = john\.smith@example\.com

[receiver]
name = Mario Rossi   # He\'s a big guy
email = mario\.rossi@example\.com
.fi
.IP "" 0
.SH "SUPPORTED SYNTAXES"
During the years several interpretations of INI files appeared\. In some implementations the colon character (\fB:\fR) was adopted as delimiter between keys and values instead of the classic equals sign (a typical example under \fBGNU\fR is \fB/etc/nsswitch\.conf\fR); in other implementations, under the influence of Unix standard configuration files, a sequence of one or more spaces (\fB/[ \et\ev\ef]+/\fR or \fB/(?:\e\e(?:\en\er?|\er\en?)|[\et \ev\ef])+/\fR) was adopted instead (see for example \fB/etc/host\.conf\fR)\.
.P
Equals sign used as delimiter between keys and values:
.IP "" 4
.nf
# example1\.ini

home = Champ de Mars, 5 Avenue Anatole
city = Paris
.fi
.IP "" 0
.P
Colon sign used as delimiter between keys and values:
.IP "" 4
.nf
# example2\.ini

home: Champ de Mars, 5 Avenue Anatole
city: Paris
.fi
.IP "" 0
.P
Space sequence used as delimiter between keys and values:
.IP "" 4
.nf
# example3\.ini

home	Champ de Mars, 5 Avenue Anatole
city	Paris
.fi
.IP "" 0
.P
\fBlibconfini\fR was born as a general INI parser for \fBGNU\fR, so the support of most part of INI dialects has been implemented within it\.
.P
Especially in \fBMicrosoft Windows\fR a more radical syntax variation found its way into INI files: the use of semicolons, instead of new lines, as delimiter between nodes, as in the following example:
.IP "" 4
.nf
# delivery\.conf

; general options

location=Colosseum;place=Rome;[sender] name=John Smith;
email=john\.smith@example\.com;
[receiver] name=Mario Rossi; # He\'s a big guy
email=mario\.rossi@example\.com
.fi
.IP "" 0
.P
For several reasons the use of semicolons as node delimiters is not (and will never be) supported by \fBlibconfini\fR\.
.SS "KEYS"
A \fBkey\-value element\fR is identified as a string placed after a new line and followed by a key\-value delimiter – typically the equals sign (\fB=\fR) or the colon sign (\fB:\fR) or a space sequence (\fB/\es+/\fR) – which is followed by a value, which is followed by a new line or an inline comment\.
.P
Both the \fBkey part\fR and the \fBvalue part\fR may be enclosed within quotes (\fB\'\fR or \fB"\fR):
.IP "" 4
.nf
foo = \'bar\'
"hello" = world
"artist" = "Pablo Picasso"
.fi
.IP "" 0
.P
The \fBkey part\fR can contain any character, except the delimiter (although this may be enclosed within quotes for not beeing considered as such)\. In multi\-line formats internal new line sequences must be escaped (\fB/\e\e(?:\en\er?|\er\en?)/\fR)\.
.P
If the \fBkey part\fR part is missing \fBlibconfini\fR considers the element of \fIunknown type\fR (example: \fB= foo\fR)\. If the \fBvalue part\fR is missing the key element is considered empty (example: \fBfoo =\fR)\. If the delimiter is missing (and therefore the value part as well), according to some formats the key element is is considered to be an \fIimplicit key\fR – typically representing the boolean \fBtrue\fR (example: \fBfoo\fR)\. For instance, in the following example from \fB/etc/pacman\.conf\fR, \fBIgnorePkg\fR is an empty key, while \fBColor\fR is an implicit key representing a \fBtrue\fR boolean – i\.e\. \fBColor = YES\fR:
.IP "" 4
.nf
HoldPkg = pacman glibc
Architecture = auto
IgnorePkg =
Color
SigLevel = Required DatabaseOptional
LocalFileSigLevel = Optional
.fi
.IP "" 0
.P
The \fBvalue\fR part can contain typed data, usually: a boolean (booleans supported by \fBlibconfini\fR are: \fBFALSE\fR/\fBTRUE\fR, \fBNO\fR/\fBYES\fR, \fBOFF\fR/\fBON\fR – case\-insensitive), a string, a number, or an array (typically with commas or spaces as delimiters between members – examples: \fBpaths = /etc, /usr, /home/john/Personal Data\fR or \fBpaths = /etc /usr "/home/john/Personal Data"\fR)\. In multi\-line formats internal new line sequences must be escaped (\fB/\e\e(?:\en\er?|\er\en?)/\fR)\.
.IP "" 4
.nf
[my_section]

my_string = "Hello world"
\'my_number\' = 42
my_boolean = NO
my_implicit_boolean
my_array = Asia, Africa, \'North America\', South America, \e
           Antarctica, Europe, Australia
.fi
.IP "" 0
.SS "SECTIONS"
A \fBsection\fR can be imagined as a directory\. A \fBsection path\fR is identified as the string \fB"$1"\fR in the regular expression \fB/(?:^|\en|\er)[ \et\ev\ef]*\e[[ \et\ev\ef]*([^\e]]*)[ \et\ev\ef]*\e][ \et\ev\ef]*(?:\en|\er|$)/\fR globally applied to an INI file\. A section path expresses nesting using the “dot\(rs character, as in the following example:
.IP "" 4
.nf
[section]

foo = bar

[section\.subsection]

foo = bar
.fi
.IP "" 0
.P
A section path starting with a dot expresses nesting to the previous section\. Hence, the last example is equivalent to:
.IP "" 4
.nf
[section]

foo = bar

[\.subsection]

foo = bar
.fi
.IP "" 0
.P
Keys appearing before any section path belong to a virtual \fIroot\fR node (with an empty string as path), as the key \fBfoo\fR in the following example:
.IP "" 4
.nf
foo = bar

[options]

interval = 3600

[host]

address = 127\.0\.0\.1
port = 80
.fi
.IP "" 0
.P
Section parts may be enclosed within quotes:
.IP "" 4
.nf
["world"\.europe\.\'germany\'\.berlin]

foo = bar
.fi
.IP "" 0
.SS "COMMENTS"
Comments are string segments enclosed within the sequence \fB/(?:^|\es)[;#]/\fR and a new line sequence, as in the following example:
.IP "" 4
.nf
# this is a comment

foo = bar       # this is an inline comment

; this is another comment
.fi
.IP "" 0
.P
Comments may in theory be multi\-line, following the same syntax of multi\-line disabled entries (see below)\. This is usually of little utility, except for inline comments you want to make sure will refer to the previous entry:
.IP "" 4
.nf
play1 = The Tempest

play2 = Twelfth Night # If music be the food of love, play on;      \e
                      # Give me excess of it; that, surfeiting,     \e
                      # The appetite may sicken, and so die\.        \e
                      # That strain again; it had a dying fall:     \e
                      # O, it came oer my ear, like the sweet sound \e
                      # That breathes upon a bank of violets,       \e
                      # Stealing, and giving odour! Enough! No more\.\e
                      # \'Tis not so sweet now as it was before\.     \e
                      #                                             \e
                      #     Orsino, scene I

# This is also a masterpiece
play3 = The Merchant of Venice
.fi
.IP "" 0
.SS "DISABLED ENTRIES"
A disabled entry is either a section or a key that has been nested inside a comment as its only child\. Inline comments cannot represent disabled entries\. According to some formats disabled entries can be multi\-line, using \fB/\e\e(?:\en\er?|\er\en?)[\et \ev\ef]*[;#]/\fR as multi\-line escape sequence\. For example:
.IP "" 4
.nf
#this = is \e
 #a \e
    #multi\-line \e
#disabled \e
  #entry
.fi
.IP "" 0
.SS "ESCAPE SEQUENCES"
In order to maximize the flexibility of the data, only four escape sequences are supported by \fBlibconfini\fR: \fB\e\'\fR, \fB\e"\fR, \fB\e\e\fR and the multi\-line escape sequence (\fB/\e\e(?:\en\er?|\er\en?)/\fR)\.
.P
The first three escape sequences are left untouched by all functions except \fBini_string_parse()\fR and \fBini_unquote()\fR (see below)\. Nevertheless, the characters \fB\'\fR, \fB"\fR and \fB\e\fR can determine different behaviors during the parsing depending on whether they are escaped or unescaped\. For instance, the string \fBjohnsmith !"\fR in the following example will not be parsed as a comment:
.IP "" 4
.nf
[users\.jsmith]

comment = "hey! have a look at my hashtag #johnsmith !"
.fi
.IP "" 0
.P
A particular case of escape sequence is the multi\-line escape sequence (\fB/\e\e(?:\en\er?|\er\en?)/\fR), which in multi\-line INI files gets \fIimmediately unescaped\fR by \fBlibconfini\fR\.
.IP "" 4
.nf
mykey = \e
	this \e
	is \e
	a \e
	multi\-line \e
	value
.fi
.IP "" 0
.SH "GETTING STARTED"
The API is contained in one single public header:
.IP "" 4
.nf
#include <confini\.h>
.fi
.IP "" 0
.P
When \fBlibconfini\fR is used as a shared library, it might be wiser to include \fIthe versioned header\fR (with only the major version number appended to the file name), in order to ensure that the code will compile correctly even when different major versions of the library cohabit in the same machine\. This can apply also to version 1\.X\.X:
.IP "" 4
.nf
#include <confini\-1\.h>
.fi
.IP "" 0
.SH "READING AN INI FILE"
\fB1\. Using a pointer to a \fBFILE\fR handle:\fR
.IP "" 4
.nf
int load_ini_file (
    FILE * ini_file,
    IniFormat format,
    IniStatsHandler f_init,
    IniDispHandler f_foreach,
    void * user_data
)
.fi
.IP "" 0
.P
\fB2\. Using a path:\fR
.IP "" 4
.nf
int load_ini_path (
    const char * path,
    IniFormat format,
    IniStatsHandler f_init,
    IniDispHandler f_foreach,
    void * user_data
)
.fi
.IP "" 0
.P
\fBWhere:\fR
.IP "\[ci]" 4
\fBini_file\fR in \fBload_ini_file()\fR is the \fBFILE\fR handle pointing to the INI file
.IP "\[ci]" 4
\fBpath\fR in \fBload_ini_path()\fR is the path where the INI file is located (pointer to a char array, a\.k\.a\. a "C string")
.IP "\[ci]" 4
\fBformat\fR is a bitfield that defines the syntax of the INI file (see \fBstruct\fR \fBIniFormat\fR)
.IP "\[ci]" 4
\fBf_init\fR is the function that will be invoked \fIbefore\fR any dispatching begins – it can be \fBNULL\fR
.IP "\[ci]" 4
\fBf_foreach\fR is the callback function that will be repeatedly invoked for each member of the INI file \- it can be \fBNULL\fR
.IP "\[ci]" 4
\fBuser_data\fR is a pointer to a custom argument – it can be \fBNULL\fR
.IP "" 0
.P
The user given function \fBf_init\fR (see \fBIniStatsHandler\fR data type) will be invoked with two arguments:
.IP "\[ci]" 4
\fBstatistics\fR – a pointer to an \fBIniStatistics\fR object containing some properties about the file read (like its size in bytes and the number of its members)
.IP "\[ci]" 4
\fBuser_data\fR – a pointer to the custom argument previously passed to the \fBload_ini_file()\fR / \fBload_ini_path()\fR functions
.IP "" 0
.P
The user given function \fBf_foreach\fR (see \fBIniDispHandler\fR data type) will be invoked with two arguments:
.IP "\[ci]" 4
\fBdispatch\fR – a pointer to an \fBIniDispatch\fR object containing the parsed member of the INI file
.IP "\[ci]" 4
\fBuser_data\fR – a pointer to the custom argument previously passed to the \fBload_ini_file()\fR / \fBload_ini_path()\fR functions
.IP "" 0
.P
Both functions \fBload_ini_file()\fR and \fBload_ini_path()\fR will return zero if the INI file has been completely dispatched, non\-zero otherwise\.
.SS "BASIC EXAMPLES"
\fBExample 1\. Using a pointer to a \fBFILE\fR handle:\fR
.IP "" 4
.nf
/*  examples/topics/load_ini_file\.c  */

#include <stdio\.h>
#include <confini\.h>

static int my_callback (
  IniDispatch * const dispatch,
  void * const v_null
) {

  printf(
    "DATA: %s\enVALUE: %s\enNODE TYPE: %u\en\en",
    dispatch\->data, dispatch\->value, dispatch\->type
  );

  return 0;

}

int main () {

  FILE * const ini_file = fopen("\.\./ini_files/delivery\.conf", "rb");

  if (ini_file == NULL) {

    fprintf(stderr, "File doesn\'t exist :\-(\en");
    return 1;

  }

  if (
    load_ini_file(
      ini_file,
      INI_DEFAULT_FORMAT,
      NULL,
      my_callback,
      NULL
    )
  ) {

    fprintf(stderr, "Sorry, something went wrong :\-(\en");
    return 1;

  }

  fclose(ini_file);

  return 0;

}
.fi
.IP "" 0
.P
\fBExample 2\. Using a path:\fR
.IP "" 4
.nf
/*  examples/topics/load_ini_path\.c  */

#include <stdio\.h>
#include <confini\.h>

static int my_callback (
  IniDispatch * const dispatch,
  void * const v_null
) {

  printf(
    "DATA: %s\enVALUE: %s\enNODE TYPE: %u\en\en",
    dispatch\->data, dispatch\->value, dispatch\->type
  );

  return 0;

}

int main () {

  if (
    load_ini_path(
      "\.\./ini_files/delivery\.conf",
      INI_DEFAULT_FORMAT,
      NULL,
      my_callback,
      NULL
    )
  ) {

    fprintf(stderr, "Sorry, something went wrong :\-(\en");
    return 1;

  }

  return 0;

}
.fi
.IP "" 0
.SS "HOW IT WORKS"
The function \fBload_ini_path()\fR is a clone of \fBload_ini_file()\fR that requires a path instead of a \fBFILE\fR handle\.
.P
Both functions \fBload_ini_file()\fR and \fBload_ini_path()\fR dynamically allocate at once the whole INI file into the heap, and the two structures \fBIniStatistics\fR and \fBIniDispatch\fR into the stack\. All members of the INI file are then dispatched to the custom listener \fBf_foreach()\fR\. Finally, the allocated memory gets automatically freed\.
.P
Because of this mechanism \fIit is very important that all the dispatched data be \fBimmediately\fR copied by the user (when needed), and no pointers to the passed data be saved\fR: after the end of the functions \fBload_ini_file()\fR / \fBload_ini_path()\fR all the allocated data will be destroyed indeed – and moreover each dispatch might overwrite data from previous dispatches\.
.P
Within a dispatching cycle, the structure containing each dispatch (\fBIniDispatch * dispatch\fR) is always the same \fBstruct\fR that gets constantly updated with new information\.
.P
\fI\fBNote:\fR On some platforms, such as Microsoft Windows, it might be necessary to add the binary specifier (\fB"b"\fR) to the mode string of the \fBFILE\fR handle passed to \fBload_ini_file()\fR in order to prevent discrepancies between the physical size and the computed size of the file\. Adding the binary specifier guarantees portability across all platforms:\fR
.IP "" 4
.nf
FILE * ini_file = fopen("example\.conf", "rb");
.fi
.IP "" 0
.SH "PARSING A BUFFER INSTEAD OF A FILE"
Starting from version 1\.10\.0, it is possible to parse a disposable buffer containing an INI file instead of a physical file (i\.e\. to parse a \fBchar\fR array)\. The function that allows to do so is named \fBstrip_ini_cache()\fR\. This function presents some important differences compared to \fBload_ini_file()\fR and \fBload_ini_path()\fR:
.IP "1." 4
As the name suggests, the buffer passed is not left untouched, but gets tokenized and rearranged instead – if you want to keep the original buffer you must pass a copy of it to \fBstrip_ini_cache()\fR – you can use \fBstrndup()\fR for this, or use the example below
.IP "2." 4
No memory is freed after the dispatching cycle is over: getting rid of the disposable buffer is something that must be done manually
.IP "3." 4
The strings dispatched are all tokens from the buffer passed as argument (no new memory is ever allocated), but the existence of each token is granted only for a short time, that is \fIuntil the dispatch of the next node\fR (in fact the latter may overwrite previous information) – therefore, as with \fBload_ini_file()\fR and \fBload_ini_path()\fR, every needed information must be copied immediately with each dispatch
.IP "4." 4
After the dispatching cycle is over, the buffer passed as argument must be regarded as \fIunreliable information\fR (portions of it might have been repeatedly overwritten and corrupted by subsequent dispatches)
.IP "" 0
.P
In short, \fBstrip_ini_cache()\fR works exactly like \fBload_ini_file()\fR and \fBload_ini_path()\fR, but with the difference that it destroys the input while it dispatches it\. And of course the input is not anymore a file, but a disposable buffer instead\. As a matter of fact, \fBstrip_ini_cache()\fR is the main parsing function both \fBload_ini_file()\fR and \fBload_ini_path()\fR rely on in order to dispatch the content of an INI file\. For a sample usage, please see \fBexamples/topics/strip_ini_cache\.c\fR\.
.P
If you want to automatize the process of making a copy of a read\-only buffer, strip and parse the copy, then free the allocated memory, you can use the following function:
.IP "" 4
.nf
/*  examples/utilities/load_ini_buffer\.h  */

#include <stdio\.h>
#include <string\.h>
#include <confini\.h>

int load_ini_buffer (
  const char * const ini_buffer,
  const size_t ini_length,
  const IniFormat format,
  const IniStatsHandler f_init,
  const IniDispHandler f_foreach,
  void * const user_data
) {

  char * const ini_cache = malloc(ini_length);

  if (!ini_cache) {

    return CONFINI_ENOMEM;

  }

  memcpy(ini_cache, ini_buffer, ini_length);

  const int retval = strip_ini_cache(
    ini_cache,
    ini_length,
    format,
    f_init,
    f_foreach,
    user_data
  );

  free(ini_cache);

  return retval;

}
.fi
.IP "" 0
.P
The function above can then be invoked directly on a \fBconst\fR buffer:
.IP "" 4
.nf
load_ini_buffer(
  my_const_buffer,
  strlen(my_const_buffer),
  my_format,
  my_stats_handler,
  my_callback,
  my_other_data
);
.fi
.IP "" 0
.P
Since in most cases an INI buffer \fIis\fR a disposable buffer (unless one wants to parse the very same buffer more than once), \fBlibconfini\fR\'s interface does not include the function in the example above\.
.SH "THE `IniFormat` data type"
For a correct use of this library it is helpful to understand the \fBIniFormat\fR data type\. \fBlibconfini\fR has been born as a general INI parser, with the main purpose of \fIbeing able to parse INI files written by other programs\fR (see \fBRationale\fR), therefore some flexibility was required\. When an INI file is parsed it is parsed according to a particular format\. The \fBIniFormat\fR data type is a univocal description of such format\. It is implemented as a 24\-bit bitfield\. Its small size (3 bytes) allows it to be passed by value to the functions that require it\.
.P
Since no function requires a pointer to an \fBIniFormat\fR data type as argument, a preprocessor macro can be a good place where to store a custom format:
.IP "" 4
.nf
#define MY_FORMAT \e
  ((IniFormat) { \e
    \.delimiter_symbol = INI_EQUALS, \e
    \.case_sensitive = false, \e
    \.semicolon_marker = INI_IGNORE, \e
    \.hash_marker = INI_IGNORE, \e
    \.section_paths = INI_ABSOLUTE_AND_RELATIVE, \e
    \.multiline_nodes = INI_MULTILINE_EVERYWHERE, \e
    \.no_single_quotes = false, \e
    \.no_double_quotes = false, \e
    \.no_spaces_in_names = false, \e
    \.implicit_is_not_empty = false, \e
    \.do_not_collapse_values = false, \e
    \.preserve_empty_quotes = false, \e
    \.disabled_after_space = false, \e
    \.disabled_can_be_implicit = false \e
  })

if (load_ini_path("example\.conf", MY_FORMAT, NULL, my_cb, NULL)) {

  fprintf(stderr, "Sorry, something went wrong :\-(\en");
  return 1;

}
.fi
.IP "" 0
.SS "THE MODEL FORMATS"
A default format named \fBINI_DEFAULT_FORMAT\fR is available\.
.IP "" 4
.nf
IniFormat my_default_format;

my_default_format = INI_DEFAULT_FORMAT;
.fi
.IP "" 0
.P
The code above corresponds to:
.IP "" 4
.nf
IniFormat my_default_format;

my_default_format\.delimiter_symbol = INI_EQUALS;  // or \'=\'
my_default_format\.case_sensitive = false;
my_default_format\.semicolon_marker = INI_DISABLED_OR_COMMENT;
my_default_format\.hash_marker = INI_DISABLED_OR_COMMENT;
my_default_format\.section_paths = INI_ABSOLUTE_AND_RELATIVE;
my_default_format\.multiline_nodes = INI_MULTILINE_EVERYWHERE;
my_default_format\.no_single_quotes = false;
my_default_format\.no_double_quotes = false;
my_default_format\.no_spaces_in_names = false;
my_default_format\.implicit_is_not_empty = false;
my_default_format\.do_not_collapse_values = false;
my_default_format\.preserve_empty_quotes = false;
my_default_format\.disabled_after_space = false;
my_default_format\.disabled_can_be_implicit = false;
.fi
.IP "" 0
.P
or, equivalently, in macro form:
.IP "" 4
.nf
#define my_default_format \e
  ((IniFormat) { \e
    \.delimiter_symbol = INI_EQUALS,  /*  or \'=\'  */ \e
    \.case_sensitive = false, \e
    \.semicolon_marker = INI_DISABLED_OR_COMMENT, \e
    \.hash_marker = INI_DISABLED_OR_COMMENT, \e
    \.section_paths = INI_ABSOLUTE_AND_RELATIVE, \e
    \.multiline_nodes = INI_MULTILINE_EVERYWHERE, \e
    \.no_single_quotes = false, \e
    \.no_double_quotes = false, \e
    \.no_spaces_in_names = false, \e
    \.implicit_is_not_empty = false, \e
    \.do_not_collapse_values = false, \e
    \.preserve_empty_quotes = false, \e
    \.disabled_after_space = false, \e
    \.disabled_can_be_implicit = false \e
  })
.fi
.IP "" 0
.P
Starting from version 1\.7\.0 a format named \fBINI_UNIXLIKE_FORMAT\fR is available\.
.IP "" 4
.nf
IniFormat my_unixlike_format = INI_UNIXLIKE_FORMAT;
.fi
.IP "" 0
.P
This format is a clone of \fBINI_DEFAULT_FORMAT\fR with the only exception of \fBIniFormat::delimiter_symbol\fR, whose value is set to \fBINI_ANY_SPACE\fR instead of \fBINI_EQUALS\fR\.
.P
The semantics of the \fBIniFormat\fR bitfield has been designed to ensure that when all its fields are set to zero it equals \fBINI_UNIXLIKE_FORMAT\fR\.
.IP "" 4
.nf
IniFormat format_zero = (IniFormat) { 0 };

printf(

  "`format_zero` and `INI_UNIXLIKE_FORMAT` are %s\.\en",

  memcmp(&format_zero, &INI_UNIXLIKE_FORMAT, sizeof(IniFormat)) ?
    "not equal"
  :
    "equal"

); // "`format_zero` and `INI_UNIXLIKE_FORMAT` are equal\."
.fi
.IP "" 0
.P
For further formats, please refer to the extensible list of common formats \fIhttps://github\.com/madmurphy/libconfini/wiki/INI\-formats\fR in the project\'s wiki\. Feel free to contribute\.
.SH "THE `IniFormatNum` data type"
Each format can be represented also as a univocal 24\-bit unsigned integer\. In order to convert an \fBIniFormat\fR to an unsigned integer and vice versa the functions \fBini_fton()\fR and \fBini_ntof()\fR are available\. For simplicity, instead of using a \fBuint_least32_t\fR type, a size\-agnostic custom type is used for this: the \fBIniFormatNum\fR data type\.
.P
For instance, imagine we want to create a format as close as possible to the typical Windows INI files\. Probably we would define our format as follows:
.IP "" 4
.nf
IniFormat my_format = {
  \.delimiter_symbol = INI_EQUALS,
  \.case_sensitive = false,
  \.semicolon_marker = INI_ONLY_COMMENT,
  \.hash_marker = INI_IS_NOT_A_MARKER,
  \.section_paths = INI_ABSOLUTE_ONLY,
  \.multiline_nodes = INI_NO_MULTILINE,
  \.no_single_quotes = false,
  \.no_double_quotes = false,
  \.no_spaces_in_names = false,
  \.implicit_is_not_empty = false,
  \.do_not_collapse_values = false,
  \.preserve_empty_quotes = false,
  \.disabled_after_space = false,
  \.disabled_can_be_implicit = false
};

IniFormatNum my_format_num = ini_fton(my_format);

printf("Format No\. %u\en", my_format_num); // "Format No\. 56637"
.fi
.IP "" 0
.P
According to the \fBini_fton()\fR function this format is univocally the format No\. 56637\. The function \fBini_ntof()\fR then gives us a shortcut to construct the very same format using its format number\. Hence, the code above corresponds to:
.IP "" 4
.nf
IniFormat my_format = ini_ntof(56637);
.fi
.IP "" 0
.SH "THE `IniStatistics` and `IniDispatch` structures"
When the functions \fBload_ini_file()\fR, \fBload_ini_path()\fR read an INI file, or when the function \fBstrip_ini_cache()\fR parses a buffer, they dispatch the file content to the \fBf_foreach()\fR listener\. Before the dispatching begins some statistics about the parsed file can be dispatched to the \fBf_init()\fR listener (if this is non\-\fBNULL\fR)\.
.P
The information passed to \fBf_init()\fR is passed through an \fBIniStatistics\fR structure, while the information passed to \fBf_foreach()\fR is passed through an \fBIniDispatch\fR structure\.
.SH "RENDERING"
The output strings dispatched by \fBlibconfini\fR follow some formatting rules depending on their role within the INI file\. First, multi\-line escape sequences will be unescaped, then
.IP "\[ci]" 4
\fBKey names\fR will be rendered according to ECMAScript \fBkey_name\.replace(/^[\en\er]\es*|\es+/g, " ")\fR – within single or double quotes, if active, the text will be rendered verbatim\.
.IP "\[ci]" 4
\fBSection paths\fR, if format supports nesting, will be rendered according to ECMAScript \fBsection_name\.replace(/\e\.*\es*$|(?:\es*(\e\.))+\es*|^\es+/g, "$1")\.replace(/\es+/g, " ")\fR – within single or double quotes, if active, the text will be rendered verbatim – otherwise, will be rendered according to the same algorithm used for key names\.
.IP "\[ci]" 4
\fBValues\fR, if \fBformat\.do_not_collapse_values\fR is active, will only be cleaned of spaces at the beginning and at the end; otherwise will be rendered according to the same algorithm used for key names (with the difference that, if \fBformat\.preserve_empty_quotes\fR is set to \fBtrue\fR, empty quotes surrounded by spaces will be preserved)\.
.IP "\[ci]" 4
\fBComments\fR, in multi\-line formats, will be rendered according to ECMAScript \fBcomment_string\.replace(/(^|\en\er?|\er\en?)[ \et\ev\ef]*[#;]+/g, "$1")\fR; elsewhere, according to ECMAScript \fBcomment_string\.replace(/^[ \et\ev\ef]*[#;]+/, "")\fR\.
.IP "\[ci]" 4
\fBUnknown nodes\fR will be rendered verbatim\.
.IP "" 0
.SH "STRING COMPARISONS"
In order to perform comparisons between the strings dispatched the functions \fBini_string_match_ss()\fR, \fBini_string_match_si()\fR, \fBini_string_match_ii()\fR and \fBini_array_match()\fR are available\. The function \fBini_string_match_ss()\fR compares two simple strings, the function \fBini_string_match_si()\fR compares a simple string with an unparsed INI string, the function \fBini_string_match_ii()\fR compares two unparsed INI strings, and the function \fBini_array_match()\fR compares two INI arrays\. INI strings are the strings typically dispatched by \fBload_ini_file()\fR, \fBload_ini_path()\fR or \fBstrip_ini_cache()\fR which may contain quotes and the three escape sequences \fB\e\e\fR, \fB\e\'\fR, \fB\e"\fR\. Simple strings are user\-given strings or the result of \fBini_string_parse()\fR\.
.P
As a consequence, the functions \fBini_string_match_si()\fR, \fBini_string_match_ii()\fR and \fBini_array_match()\fR do not perform literal comparisons of equality between strings\. For example, in the following (absurd) INI file the two keys \fBfoo\fR and \fBhello\fR belong to the same section named \fBthis is a double quotation mark: "!\fR (after being parsed by \fBini_string_parse()\fR)\.
.IP "" 4
.nf
[this is a double quotation mark: \e"!]

foo = bar

[this is a double quotation mark: \'"\'!]

hello = world
.fi
.IP "" 0
.P
Therefore\|\.\|\.\|\.
.IP "" 4
.nf
char
  string1[] = "This is a double quotation mark: \e\e\e"!",
  string2[] = "This is a double quotation mark: \'\e"\'!";

printf(
  "%s\en",

  ini_string_match_ii(string1, string2, INI_DEFAULT_FORMAT) ?
    "They match"
  :
    "They don\'t match"
);  // "They match"
.fi
.IP "" 0
.P
Or, for instance, in the following example the first two arrays are considered equal, while the third one is considered different\.
.IP "" 4
.nf
#include <stdio\.h>
#include <confini\.h>

int main () {

  char
    list_1[] = "foo:bar  :  apple : \'I said: wait!\' :   bye bye  ",
    list_2[] = "\'foo\':\'bar\':\'apple\':\'I said: wait!\':\'bye\'   bye",
    list_3[] = "foo:bar:tomorrow:apple:I said: wait!:bye bye";

  printf(
    "%s\en",
    ini_array_match(list_1, list_2, \':\', INI_DEFAULT_FORMAT) ?
      "They match"
    :
      "They don\'t match"
  );  // "They match"


  printf(
    "%s\en",
    ini_array_match(list_1, list_3, \':\', INI_DEFAULT_FORMAT) ?
      "They match"
    :
      "They don\'t match"
  );  // "They don\'t match"

  return 0;

}
.fi
.IP "" 0
.P
In formats that support quotes, the function \fBini_array_match()\fR is also the function that should be used, with \fB\'\.\'\fR, or \fBINI_DOT\fR, as delimiter (see \fBenum\fR \fBIniDelimiters\fR), to compare properly section paths containing more than one level of nesting\.
.IP "" 4
.nf
if (
  ini_array_match("foo\.bar", disp\->append_to, \'\.\', disp\->format) &&
  ini_string_match_si("username", disp\->data, disp\->format)
) {

  // Do something

}
.fi
.IP "" 0
.P
In case of multiple comparisons you might want to use a macro:
.IP "" 4
.nf
static int my_callback (IniDispatch * dsp, void * v_my_data) {

  #define IS_KEY(SECTION, KEY) \e
    (ini_array_match(SECTION, dsp\->append_to, \'\.\', dsp\->format) && \e
    ini_string_match_ii(KEY, dsp\->data, dsp\->format))

  if (dsp\->type == INI_KEY) {

    if (IS_KEY("europe\.madrid", "have_visited")) {

      // Do something

    } else if (IS_KEY("europe\.london", "date")) {

      // Do something

    } else if (\|\.\|\.\|\.) {

      // etc\.

    }

  }

  #undef IS_KEY

}
.fi
.IP "" 0
.P
The four functions \fBini_string_match_ss()\fR, \fBini_string_match_si()\fR, \fBini_string_match_ii()\fR, \fBini_array_match()\fR perform case\-sensitive or case\-insensitive comparisons depending on the format given\. The comparison between UTF\-8 codepoints out of the ASCII range is always case\-sensitive\.
.P
Note that within INI strings empty quotes and spaces out of quotes are always collapsed during comparisons\. Furthermore, remember that the multi\-line escape sequence \fB/\e\e(?:\en\er?|\er\en?)/\fR is \fInot\fR considered as such in INI strings, as this is the only escape sequence automatically unescaped by \fBlibconfini\fR before each dispatch\.
.SH "ARRAYS"
It is possible with \fBlibconfini\fR to parse INI values as arrays\. In order to avoid that any particular character be treated as a metacharacter throughout an entire configuration file, INI arrays do not have a fixed delimiter symbol specified in the INI format\.
.P
Abstractly speaking, this means that array delimiters are not part of the INI syntax, but of the INI semantics instead\. Concretely speaking, this means that developers have to provide a delimiter each time they decide to parse an INI string as an array\.
.P
Out in the wild, the most widespread INI array delimiter is probably the space sequence (\fBINI_ANY_SPACE\fR)\. Another widespread delimiter is the comma (\fB\',\'\fR or \fBINI_COMMA\fR)\. Besides these two, other characters can occasionally be found as array delimiters too (\fB\':\'\fR, \fB\'|\'\fR, \fB\';\'\fR, etc\.)\.
.P
For iterating through an INI array using a delimiter, \fBlibconfini\fR provides the following functions:
.IP "\[ci]" 4
\fBini_array_get_length()\fR
.IP "\[ci]" 4
\fBini_array_foreach()\fR
.IP "\[ci]" 4
\fBini_array_collapse()\fR
.IP "\[ci]" 4
\fBini_array_break()\fR
.IP "\[ci]" 4
\fBini_array_release()\fR
.IP "\[ci]" 4
\fBini_array_shift()\fR
.IP "\[ci]" 4
\fBini_array_split()\fR
.IP "" 0
.P
None of the functions above actually ever allocates any array, as \fBlibconfini\fR does not know what kind of data type an array should be composed of – the developer might be looking for an array of strings, or an array of integers, or anything else\. These tools only provide safe mechanisms to tokenize or iterate through the members of INI arrays according to the format and the delimiter given – making sure, for example, that when the delimiter symbol is found nested within quotes it is treated as a normal character, and so on – but allocating memory is something that must be done manually\.
.P
An example function that parses INI strings as newly allocated arrays of C strings is available under \fBexamples/utilities/make_strarray\.h\fR\. If your program requires other data types (such as integers, booleans, etc\.) you may adapt that example to your needs\.
.SH "EDITING THE DISPATCHED DATA"
The strings dispatched, as already said, must not be freed\. Nevertheless, \fIbefore being copied or analyzed they can be edited, \fBwith some precautions\fR\fR:
.IP "1." 4
Be sure that your edit remains within the buffer lengths given (see \fBIniDispatch::d_len\fR and \fBIniDispatch::v_len\fR)\.
.IP "2." 4
Do not edit the \fBIniDispatch::data\fR field of a section: the \fBIniDispatch::append_to\fR properties of its children will either share this buffer or will concatenate it to another buffer\. If you edit its content – and depending on how you edit it – you might be no more able to rely on the \fBIniDispatch::append_to\fR properties of this node\'s children (you would not make any damage, the loop will continue just fine – if you think you are never going to use the property \fBIniDispatch::append_to\fR, just do it; alternatively, use \fBstrndup()\fR)\.
.IP "3." 4
If \fBIniDispatch::data\fR contains a key name or a comment, it is guaranteed that no other dispatch will share this buffer, so feel free to edit it before it gets lost\.
.IP "4." 4
Regarding \fBIniDispatch::value\fR, if it does not represent an implicit value (see \fB\(sc Implicit keys\fR) or if \fBIniFormat::implicit_is_not_empty\fR is set to \fBfalse\fR, this buffer is never shared between dispatches, so feel free to edit it\.
.IP "5." 4
The buffer pointed by \fBIniDispatch::append_to\fR is likely to be shared with other dispatches\. Again, you would not destroy the world nor generate errors, but you would make the next \fBIniDispatch::append_to\fRs useless\. For this reason \fBthe buffer pointed by \fBIniDispatch::append_to\fR is passed as constant\fR\. To unquote the path parts listed in this field please use \fBstrndup()\fR\.
.IP "6." 4
The numerical addresses of the pointers \fBIniDispatch::data\fR, \fBIniDispatch::value\fR and \fBIniDispatch::append_to\fR and the fields \fBIniDispatch::type\fR, \fBIniDispatch::d_len\fR, \fBIniDispatch::v_len\fR and \fBIniDispatch::at_len\fR, are constantly reset, so feel free to use them as custom placeholders if you like – but check their types: \fBIniDispatch::type\fR has only eight bits available and \fBIniDispatch::append_to\fR will always point to a \fBconst\fR buffer\.
.IP "7." 4
The numerical field \fBIniDispatch::dispatch_id\fR will be checked right before the next dispatch, so you should not edit it\. The reading happens only as further diagnostics: if you constantly set this field to \fB0\fR the loop will still end at the right moment (hopefully), but if you set it instead to a value equal or higher than the \fBIniStatistics::members\fR previously received, the loop will immediately stop and a \fBCONFINI_EOOR\fR will be thrown (see \fBenum\fR \fBConfiniInterruptNo\fR)\. You can think of this as a dirty way to write \fBreturn !0\fR at the end of your listener\. Unless you really know what you are doing, do not edit \fBIniDispatch::dispatch_id\fR\.
.IP "" 0
.P
Typical peaceful edits are the ones obtained by calling the functions \fBini_array_collapse()\fR and \fBini_string_parse()\fR directly on the buffer \fBIniDispatch::value\fR:
.IP "" 4
.nf
/*  examples/topics/ini_string_parse\.c  */

#include <stdio\.h>
#include <confini\.h>

static int ini_listener (
  IniDispatch * const dispatch,
  void * const v_null
) {

  if (
    dispatch\->type == INI_KEY || dispatch\->type == INI_DISABLED_KEY
  ) {

    ini_unquote(dispatch\->data, dispatch\->format);
    ini_string_parse(dispatch\->value, dispatch\->format);

  }

  printf(
    "DATA: %s\enVALUE: %s\enNODE TYPE: %u\en\en",
    dispatch\->data,
    dispatch\->value,
    dispatch\->type
  );

  return 0;

}

int main () {

  if (
    load_ini_path(
      "\.\./ini_files/self_explaining\.conf",
      INI_DEFAULT_FORMAT,
      NULL,
      ini_listener,
      NULL
    )
  ) {

    fprintf(stderr, "Sorry, something went wrong :\-(\en");
    return 1;

  }

  return 0;

}
.fi
.IP "" 0
.P
If all these rules, although thoroughly exposed, still sound confusing to you, always use \fBstrndup()\fR on the strings dispatched and feel free to edit your own buffers as you wish\. Under \fBexamples/utilities/clone_ini_dispatch\.h\fR you can find a function designed to make a hard copy of an entire \fBIniDispatch\fR, including all the strings that this points to\.
.SS "FORMATTING THE VALUES"
Once your listener starts to receive the parsed data you may want to format and better parse the \fBvalue\fR part of key\-value elements\. The following functions might be useful for this purpose:
.IP "\[ci]" 4
\fBini_get_bool()\fR
.IP "\[ci]" 4
\fBini_get_bool_i()\fR
.IP "\[ci]" 4
\fBini_string_parse()\fR
.IP "\[ci]" 4
\fBini_array_get_length()\fR
.IP "\[ci]" 4
\fBini_array_foreach()\fR
.IP "\[ci]" 4
\fBini_array_collapse()\fR
.IP "\[ci]" 4
\fBini_array_break()\fR
.IP "\[ci]" 4
\fBini_array_release()\fR
.IP "\[ci]" 4
\fBini_array_shift()\fR
.IP "\[ci]" 4
\fBini_array_split()\fR
.IP "" 0
.P
Together with the functions listed above the following links are available, in case you don\'t have \fBinclude <stdlib\.h>\fR in your source:
.IP "\[ci]" 4
\fBini_get_int()\fR = \fB\fBatoi()\fR\fR \fIhttp://www\.gnu\.org/software/libc/manual/html_node/Parsing\-of\-Integers\.html#index\-atoi\fR
.IP "\[ci]" 4
\fBini_get_lint()\fR = \fB\fBatol()\fR\fR \fIhttp://www\.gnu\.org/software/libc/manual/html_node/Parsing\-of\-Integers\.html#index\-atol\fR
.IP "\[ci]" 4
\fBini_get_llint()\fR = \fB\fBatoll()\fR\fR \fIhttp://www\.gnu\.org/software/libc/manual/html_node/Parsing\-of\-Integers\.html#index\-atoll\fR
.IP "\[ci]" 4
\fBini_get_double()\fR = \fB\fBatof()\fR\fR \fIhttp://www\.gnu\.org/software/libc/manual/html_node/Parsing\-of\-Integers\.html#index\-atof\fR
.IP "" 0
.P
Further useful resources include:
.IP "\[ci]" 4
\fBexamples/utilities/clone_ini_dispatch\.h\fR
.IP "\[ci]" 4
\fBexamples/utilities/make_strarray\.h\fR
.IP "" 0
.SS "FORMATTING THE KEY NAMES"
The function \fBini_unquote()\fR can be useful for key names enclosed within quotes\. This function is very similar to \fBini_string_parse()\fR, except that does not bother collapsing the sequences of more than one space that might result from removing empty quotes – this is never necessary, since empty quotes surrounded by spaces in key and section names are always automatically collapsed before being dispatched\.
.P
You could use \fBini_string_parse()\fR as well to parse key and section names, but you would obtain the same result with a slightly bigger effort from the CPU\.
.SS "FORMATTING THE SECTION PATHS"
In order to retrieve the parts of a section path, the functions \fBini_array_get_length()\fR, \fBini_array_foreach()\fR, \fBini_array_break()\fR, \fBini_array_release()\fR, \fBini_array_shift()\fR and \fBini_array_split()\fR can be used with \fB\'\.\'\fR or \fBINI_DOT\fR as delimiter (see \fBenum\fR \fBIniDelimiters\fR)\. Note that section paths dispatched by \fBlibconfini\fR are always collapsed arrays, therefore calling the function \fBini_array_collapse()\fR on them will have no effects\.
.P
It might be required that the function \fBini_unquote()\fR be applied to each part of a section path, depending on the content and the format of the INI file\.
.SH "IMPLICIT KEYS"
In order to set the value to assign to implicit keys (i\.e\. keys without a delimiter and a value), please use the \fBini_global_set_implicit_value()\fR function\. A \fBtrue\fR boolean is usually a good choice:
.IP "" 4
.nf
ini_global_set_implicit_value("YES", 3);
.fi
.IP "" 0
.P
Alternatively, instead of \fBini_global_set_implicit_value()\fR you can manually declare at the beginning of your code the two global variables \fBINI_GLOBAL_IMPLICIT_VALUE\fR and \fBINI_GLOBAL_IMPLICIT_V_LEN\fR, which will be retrieved by \fBlibconfini\fR:
.IP "" 4
.nf
#include <confini\.h>

char * INI_GLOBAL_IMPLICIT_VALUE = "YES";
size_t INI_GLOBAL_IMPLICIT_V_LEN = 3;
.fi
.IP "" 0
.P
Or you can assign a value to them at the beginning of the \fBmain()\fR function of your program:
.IP "" 4
.nf
#include <confini\.h>

int main () {

  INI_GLOBAL_IMPLICIT_VALUE = "YES";
  INI_GLOBAL_IMPLICIT_V_LEN = 3;

  /* \|\.\|\.\|\. */

}
.fi
.IP "" 0
.P
If not defined elsewhere, these variables are initialized respectively to \fBNULL\fR and \fB0\fR by default\.
.P
Although the two variables \fBINI_GLOBAL_IMPLICIT_VALUE\fR and \fBINI_GLOBAL_IMPLICIT_V_LEN\fR are used only as placeholders for custom information accessible solely by the user, starting from version 1\.14\.0 it is safer to make \fBINI_GLOBAL_IMPLICIT_V_LEN\fR match \fIexactly\fR the real length of \fBINI_GLOBAL_IMPLICIT_VALUE\fR (without counting the \fBNUL\fR terminator)\. By doing so it is possible to make \fBlibconfini\fR aware of a segment of memory that must be protected from writing operations\.
.P
After having set the value to be assigned to implicit key elements and having enabled \fBIniFormat::implicit_is_not_empty\fR in the format, it is possible to test whether a dispatched key is implicit or not by comparing the address of its \fBvalue\fR property with the global variable \fBINI_GLOBAL_IMPLICIT_VALUE\fR:
.IP "" 4
.nf
/*  examples/topics/ini_global_set_implicit_value\.c  */

#include <stdio\.h>
#include <confini\.h>

static int ini_listener (
  IniDispatch * const dispatch,
  void * const v_null
) {

  if (dispatch\->value == INI_GLOBAL_IMPLICIT_VALUE) {

    printf(
      "\enDATA: %s\enVALUE: %s\enNODE TYPE: %u\en"
      "(This is an implicit key element)\en",

      dispatch\->data,
      dispatch\->value,
      dispatch\->type
    );

  } else {

    printf(
      "\enDATA: %s\enVALUE: %s\enNODE TYPE: %u\en",

      dispatch\->data,
      dispatch\->value,
      dispatch\->type
    );

  }

  return 0;

}

int main () {

  IniFormat my_format = INI_UNIXLIKE_FORMAT;

  ini_global_set_implicit_value("[implicit default value]", 24);

  /*  Without this implicit keys will be considered empty  */
  my_format\.implicit_is_not_empty = true;
  my_format\.disabled_can_be_implicit = true;

  if (
    load_ini_path(
      "\.\./ini_files/unix\-like\.conf",
      my_format,
      NULL,
      ini_listener,
      NULL
    )
  ) {

    fprintf(stderr, "Sorry, something went wrong :\-(\en");
    return 1;

  }

}
.fi
.IP "" 0
.P
Implicit keys can be parsed as booleans also without setting \fBIniFormat::implicit_is_not_empty\fR to \fBtrue\fR\. By doing so there will be no distinction between empty and implicit keys, and there are situations where this can be a wanted behavior\. The following example will parse both \fBmy_key\fR and \fBmy_key =\fR in the INI file as \fBtrue\fR:
.IP "" 4
.nf
/*  `dsp\->format\.implicit_is_not_empty` is `false` here!  */
bool my_boolean;
if (ini_string_match_si("my_key", dsp\->data, dsp\->format)) {
  my_boolean = (bool) ini_get_bool_i(dsp\->value, 1, dsp\->format);
}
.fi
.IP "" 0
.SH "CODE CONSIDERATIONS"
.SS "RETURN VALUES"
The functions \fBload_ini_file()\fR, \fBload_ini_path()\fR, \fBstrip_ini_cache()\fR, \fBini_array_foreach()\fR and \fBini_array_split()\fR require some listeners defined by the user\. Such listeners must return an \fBint\fR value\. When this is non\-zero the caller function is interrupted, its loop stopped, and a non\-zero value is returned by the caller as well\.
.P
The functions \fBload_ini_file()\fR, \fBload_ini_path()\fR and \fBstrip_ini_cache()\fR return a non\-zero value also if the INI file, for any reason, has not been completely parsed (see \fBenum\fR \fBConfiniInterruptNo\fR)\. Therefore, in order to be able to distinguish between internal errors and user\-generated interruptions the mask \fBCONFINI_ERROR\fR can be used\.
.P
For instance, in the following example the \fBf_foreach()\fR listener returns a non\-zero value if a key named \fBpassword\fR with a value that equals \fBHello world\fR is found\. Hence, by using the mask \fBCONFINI_ERROR\fR, the code below distinguishes a non\-zero value generated by the listener from a non\-zero value due to a parsing error\.
.IP "" 4
.nf
/*  examples/topics/ini_string_match_si\.c  */

#include <stdio\.h>
#include <confini\.h>

static int passfinder (
  IniDispatch * const disp,
  void * const v_membid
) {

  /*  Search for `password = "hello world"` in the INI file  */
  if (
    ini_string_match_si("password", disp\->data, disp\->format) &&
    ini_string_match_si("hello world", disp\->value, disp\->format)
  ) {

    *((size_t *) v_membid) = disp\->dispatch_id;
    return 1;

  }

  return 0;

}

int main () {

  size_t membid;

  /*  Load INI file  */
  int retval = load_ini_path(
    "\.\./ini_files/self_explaining\.conf",
    INI_DEFAULT_FORMAT,
    NULL,
    passfinder,
    &membid
  );

  /*  Check for errors  */
  if (retval & CONFINI_ERROR) {

    fprintf(stderr, "Sorry, something went wrong :\-(\en");
    return 1;

  }

  /*  Check if parsing has been interrupted by `passfinder()`  */
  retval  ==  CONFINI_FEINTR ?
                printf(
                  "We found it! It\'s the INI node number %zu!\en",
                  membid
                )
              :
                printf("We didn\'t find it :\-(\en");

  return 0;

}
.fi
.IP "" 0
.SS "THE FORMATTING FUNCTIONS"
The functions \fBini_unquote()\fR, \fBini_string_parse()\fR, \fBini_array_collapse()\fR, \fBini_array_break()\fR, \fBini_array_release()\fR and \fBini_array_split()\fR change the content of the given strings\. It is important to point out that the edit is always performed within the lengths of the strings given\.
.P
The behavior of these functions depends on the format used\. In particular, using \fBini_string_parse()\fR as a model one obtains the following scheme:
.IP "1." 4
Condition: \fB!format\.no_single_quotes && !format\.no_double_quotes && format\.multiline_nodes != INI_NO_MULTILINE\fR
.br
⇒ Escape sequences: \fB\e\e\fR, \fB\e"\fR, \fB\e\'\fR
.br
⇒ Behavior of \fBini_string_parse()\fR: \fB\e\e\fR, \fB\e\'\fR and \fB\e"\fR will be unescaped, all unescaped single and double quotes will be removed, then the new length of the string will be returned\.
.IP "2." 4
Condition: \fB!format\.no_single_quotes && format\.no_double_quotes && format\.multiline_nodes != INI_NO_MULTILINE\fR
.br
⇒ Escape sequences: \fB\e\e\fR, \fB\e\'\fR
.br
⇒ Behavior of \fBini_string_parse()\fR: \fB\e\e\fR and \fB\e\'\fR will be unescaped, all unescaped single quotes will be removed, then the new length of the string will be returned\.
.IP "3." 4
Condition: \fBformat\.no_single_quotes && !format\.no_double_quotes && format\.multiline_nodes != INI_NO_MULTILINE\fR
.br
⇒ Escape sequences: \fB\e\e\fR, \fB\e"\fR
.br
⇒ Behavior of \fBini_string_parse()\fR: \fB\e\e\fR and \fB\e"\fR will be unescaped, all unescaped double quotes will be removed, then the new length of the string will be returned\.
.IP "4." 4
Condition: \fBformat\.no_single_quotes && format\.no_double_quotes && format\.multiline_nodes != INI_NO_MULTILINE\fR
.br
⇒ Escape sequences: \fB\e\e\fR
.br
⇒ Behavior of \fBini_string_parse()\fR: only \fB\e\e\fR will be unescaped, spaces at the beginning and at the end of the string will be removed, then the new length of the string will be returned\.
.IP "5." 4
Condition: \fBformat\.no_single_quotes && format\.no_double_quotes && format\.multiline_nodes == INI_NO_MULTILINE\fR
.br
⇒ Escape sequences: No escape sequences
.br
⇒ Behavior of \fBini_string_parse()\fR: Spaces at the beginning and at the end of the string will be removed, then the new length of the string will be returned\.
.IP "" 0
.P
A function\-like macro named \fBINIFORMAT_HAS_NO_ESC()\fR is available for checking whether a format supports escape sequences or not\.
.P
It is possible to extend the list of supported escape sequences by parsing additional ones before invoking \fBini_string_parse()\fR\. Under \fBexamples/utilities/ini_string_preparse\.h\fR there is a little helper function that adds support to the following sequences: \fB"\ea"\fR, \fB"\eb"\fR, \fB"\ef"\fR, \fB"\en"\fR, \fB"\er"\fR, \fB"\et"\fR, \fB"\ev"\fR and \fB"\ee"\fR\. That function must be used right before \fBini_unquote()\fR or \fBini_string_parse()\fR, as it relies on the latter for unescaping double backslashes:
.IP "" 4
.nf
#include <confini\.h>
#include "examples/utilities/ini_string_preparse\.h"

static int my_callback (IniDispatch * disp, void * user_data) {

  if (disp\->type == INI_KEY) {

    /*  Add support for \ea, \eb, \ef, \en, \er, \et, \ev and \ee  */
    ini_string_preparse(disp\->value);
    ini_string_parse(disp\->value, disp\->format);

    /*  DO SOMETHING  */

  }

  return 0;

}
.fi
.IP "" 0
.SS "COMMON MISTAKES"
The native formatting functions \fBini_array_break()\fR, \fBini_array_collapse()\fR, \fBini_array_release()\fR, \fBini_array_split()\fR, \fBini_string_parse()\fR and \fBini_unquote()\fR have a special safeguard against attempting to edit the global variable \fBINI_GLOBAL_IMPLICIT_VALUE\fR\. But if you use your own functions for editing the dispatches received, you must always make sure that \fBdispatch\->value != INI_GLOBAL_IMPLICIT_VALUE\fR in formats where \fBIniFormat::implicit_is_not_empty\fR is set to \fBtrue\fR – otherwise a “Segmentation fault (core dumped)\(rs error can be generated\.
.IP "" 4
.nf
#include <stdio\.h>
#include <confini\.h>

static void my_editing_function (char * const my_string) {

  if (!my_string) {

    return;

  }

  /*  Only a random edit\|\.\|\.\|\.  */
  my_string[0] = \'\e0\';

}

static int my_callback (IniDispatch * dispatch, void * v_null) {

  /*
    This will always work: `libconfini` formatting function have a
    safeguard against attempting to edit the global variable
    `INI_GLOBAL_IMPLICIT_VALUE`\|\.\|\.\|\.
  */
  ini_string_parse(dispatch\->value, dispatch\->format);

  /*
    This can cause a `Segmentation fault (core dumped)` error when
    `dispatch\->format\.implicit_is_not_empty` is set to `true` and
    `dispatch\->value` is an implicit boolean\. In cases like this, if
    you don\'t want to `strndup(dispatch\->value, dispatch\->v_len)`,
    you must always check that
   `dispatch\->value != INI_GLOBAL_IMPLICIT_VALUE`!
  */
  my_editing_function(dispatch\->value);

  printf(
    "DATA: %s\enVALUE: %s\enNODE TYPE: %u\en\en",
    dispatch\->data, dispatch\->value, dispatch\->type
  );

  return 0;

}

int main () {

  ini_global_set_implicit_value("YES", 3);
  IniFormat myformat = INI_DEFAULT_FORMAT;
  myformat\.implicit_is_not_empty = true;
  myformat\.disabled_can_be_implicit = true;

  if (load_ini_path(
    "examples/ini_files/typed_ini\.conf",
    myformat,
    NULL,
    my_callback,
    NULL
  )) {

    fprintf(stderr, "Sorry, something went wrong :\-(\en");
    return 1;

  }

  return 0;

}
.fi
.IP "" 0
.P
To check whether a particular substring belongs to \fBINI_GLOBAL_IMPLICIT_VALUE\fR, the \fBINI_IS_IMPLICIT_SUBSTR()\fR macro can be used:
.IP "" 4
.nf
if (dispatch\->v_len > 0) {

  /*  Let us create a substring of `dispatch\->value`\|\.\|\.\|\.  */
  char * my_substring = dispatch\->value + 1;

  printf("%s\en", my_substring);

  if (INI_IS_IMPLICIT_SUBSTR(my_substring)) {

    printf("\en\etYou tricky one! This was an implicit value too!\en");

  }

return 0;
.fi
.IP "" 0
.SS "STORING THE DISPATCHED DATA"
In order to be as flexible as possible, \fBlibconfini\fR does not store the dispatched data, nor indicizes them\. This gives developers the power to deal with them in many different ways\.
.P
For small INI files a normal if/else chain, using \fBini_array_match()\fR for comparing section paths and \fBini_string_match_si()\fR/\fBini_string_match_ii()\fR for comparing key names, usually represents the most practical and efficient way to obtain the information required from an INI file\. Sometimes however, especially in case of sizeable INI files, the most efficient solution would be to store the parsed data in a hash table before trying to access it\.
.P
Some INI parsers are released with a hash table API included by default\. This is an unpractical solution, since fantastic free software libraries that focus solely on hash tables already exist, and providing a further API for managing a hash function together with an INI parser only complicates the code, makes it harder to maintain, and does not give the developer the real freedom to choose what suits best to each single case\. Some programming languages even have hash tables in their standard libraries (see \fBstd::map\fR in C++ for example)\.
.P
When needed, the data parsed by \fBlibconfini\fR can be stored in a hash table while it is being dispatched\. If you are interested in combining \fBlibconfini\fR with a hash table, we have left a general example of how to use \fBGLib\fR\'s \fBGHashTable\fR together with \fBlibconfini\fR under \fBexamples/miscellanea/glib_hash_table\.c\fR\. If you are using C++, you can find an example of how to construct a C++ class that relies on a \fBstd::unordered_map\fR object under \fBexamples/cplusplus/map\.cpp\fR\. By keeping these examples as models other solutions can be easily explored as well\.
.SS "SIZE OF THE DISPATCHED DATA"
Writing
.IP "" 4
.nf
char * buf  =   malloc(stats\->bytes + stats\->members + (
                  stats\->format\.implicit_is_not_empty ?
                    INI_GLOBAL_IMPLICIT_V_LEN * stats\->members
                  :
                    0
                ) + 1);
.fi
.IP "" 0
.P
will always allocate the smallest buffer large enough to store all the \fBIniDispatch::data\fR and \fBIniDispatch::value\fR received, including their \fBNUL\fR terminators and any possible implicit value\.
.P
This buffer will not be capable enough to store also the \fBIniDispatch::append_to\fR strings received (about which no information is available at early stages)\. However, thanks to the syntax of INI files, where a key is always appended to the section previously dispatched, it will be always possible to store the information about the structure of the tree by using numbers as references to the parents instead of copying verbatim the \fBIniDispatch::append_to\fR strings\. This will also result in a more efficient code\.
.IP "" 4
.nf
#include <stdio\.h>
#include <stdlib\.h>
#include <confini\.h>

static int my_stats_listener (
  IniStatistics * stats,
  void * v_destptr
) {

  #define destptr ((char **) v_destptr)

  *destptr  =   malloc(stats\->bytes + stats\->members + (
                  stats\->format\.implicit_is_not_empty ?
                    INI_GLOBAL_IMPLICIT_V_LEN * stats\->members
                  :
                    0
                ) + 1);

  return 0;

  #undef destptr

}


static int my_ini_listener (
  IniDispatch * this,
  void * v_my_capable_buffer
) {

  /*  Store the dispatched data in `my_capable_buffer`  */
  char ** my_capable_buffer = (char **) v_my_capable_buffer;
  /*  \|\.\|\.\|\.  */

  return 0;

}

int main () {

  /*  In real life we would need a more complex `struct` here\|\.\|\.\|\.  */
  char * my_copied_data;

  /*  Load the INI file  */
  if (load_ini_path(
    "test\.conf",
    INI_DEFAULT_FORMAT,
    my_stats_listener,
    my_ini_listener,
    &my_copied_data
  )) {

    fprintf(stderr, "Sorry, something went wrong :\-(\en");
    return 1;

  }

  return 0;

}
.fi
.IP "" 0
.SS "OTHER GLOBAL SETTINGS"
In the past, besides the two global variables \fBINI_GLOBAL_IMPLICIT_VALUE\fR and \fBINI_GLOBAL_IMPLICIT_V_LEN\fR, a third variable named \fBINI_GLOBAL_LOWERCASE_MODE\fR would tell \fBlibconfini\fR whether to dispatch in lower case all key names and section paths of case\-insensitive INI files\. This variable rarely needed to be set to \fBtrue\fR, since string comparisons made by libconfini are always either case\-sensitive or case\-insensitive depending on the format given\.
.P
This “dispatch in lowercase\(rs functionality itself is a relic from a time when \fBlibconfini\fR did not yet possess any string comparison functions\. This is no longer the case, and there are now four functions for that; therefore starting from version 1\.15\.0 both the \fBINI_GLOBAL_IMPLICIT_VALUE\fR variable and the \fBini_global_set_lowercase_mode()\fR function have been marked as deprecated (see the \fBlist of deprecated functions and variables\fR)\. If needed, to convert to lowercase key names and section paths in case\-insensitive INI files it is possible to use the following simple snippet, which maps exactly what \fBlibconfini\fR would do:
.IP "" 4
.nf
static inline void string_tolower (char * const str) {
  for (register char * ptr = str; *ptr; ptr++) {
    *ptr = *ptr > 0x40 && *ptr < 0x5b ? *ptr | 0x60 : *ptr;
  }
}

static int my_callback (IniDispatch * dispatch, void * v_null) {

  if (!dispatch\->format\.case_sensitive) {
    switch (dispatch\->type) {
      case INI_KEY:
      case INI_DISABLED_KEY:
      case INI_SECTION:
      case INI_DISABLED_SECTION:
        string_tolower(dispatch\->data);
    }

  }

  /*  DO SOMETHING\|\.\|\.\|\.  */

 return 0;

}
.fi
.IP "" 0
.SS "THE UNICODE PROBLEM"
Comparing an ASCII upper case letter to an ASCII lower case letter is an invariant process\. But comparing two Unicode letter cases is a process that depends on the locale of the machine\. Consider for example the lower case letter \fBi\fR: in most European languages its upper case is \fBI\fR, while this is not the case in Turkish, where the upper case of \fBi\fR is \fBİ\fR (and the lower case of \fBI\fR is \fBı\fR)\. Therefore for a person living in Italy or France, \fBi\fR and \fBI\fR will represent the same letter, while for a person living in Turkey they will not\.
.P
Key and section names of an INI file however cannot depend on the locale of the machine, since they must be reliably searched for independently of where a machine is located\. Imagine for example a key named “INI\(rs and imagine that Unicode case folding were performed on key names during string comparisons\. If you lived in Europe you could look up for such key using its lower case “ini\(rs, while if you lived in Turkey you would have to use the lower case “ını\(rs to find it\. So the only solution is to consider Unicode characters out of the ASCII range always as case\-sensitive\. For this reason, \fBlibconfini\fR (and probably any judicious INI parser) will never perform case folding of Unicode characters out of the ASCII range within key and section names\.
.P
It must be said that most Unicode characters do not possess a lower and upper case, and most characters outside of the ASCII range could theoretically appear without problems in key and section names also in case\-insensitive INI files (think of the character \fB\(sc\fR for example)\. And, as for case\-sensitive INI files, no Unicode character would ever represent a problem\. Nonetheless, it is generally more acceptable to use ASCII only within key and section names – and possibly, if needed, non\-ASCII Unicode characters within values and comments\.
.P
That said, \fBlibconfini\fR deals perfectly fine with UTF\-8 (but is always case\-sensitive outside of the ASCII range), so use the latter as you feel appropriate\.
.SS "THREAD SAFETY"
Depending on the format of the INI file, \fBlibconfini\fR may use up to three global variables (\fBINI_GLOBAL_IMPLICIT_VALUE\fR, \fBINI_GLOBAL_IMPLICIT_V_LEN\fR and \fBINI_GLOBAL_LOWERCASE_MODE\fR)\. In order to be thread\-safe these three variables (if needed) must be defined only once (either directly, or by using their setter functions \fBini_global_set_implicit_value()\fR and \fBini_global_set_lowercase_mode()\fR), or otherwise a mutex logic must be introduced\.
.P
Apart from the three variables above, each parsing allocates and frees its own memory and every function is fully reentrant, therefore the library can be considered thread\-safe\.
.SS "ERROR EXCEPTIONS"
The philosophy of \fBlibconfini\fR is that of parsing as much as possible without generating error exceptions\. No parsing errors are returned once an INI file has been correctly allocated into the heap, with the exception of the \fIout\-of\-range\fR error \fBCONFINI_EOOR\fR (see \fBenum\fR \fBConfiniInterruptNo\fR), whose meaning is that the dispatches are for unknown reasons more than expected – this error is possibly generated by the presence of bugs in the library\'s code and should \fBnever\fR be returned (please contact me \fIhttps://github\.com/madmurphy/libconfini/issues\fR if this happens)\.
.P
When an INI node is wrongly written in respect to the format given, it is dispatched verbatim as an \fBINI_UNKNOWN\fR node – see \fBenum\fR \fBIniNodeType\fR\. Empty lines, or lines containing only spaces and empty quotes (if the latter are supported) will be skipped\.
.P
In order to avoid error exceptions, strings containing an unterminated quote will always be treated as if they had a virtual quote as their last + 1 character\. For example,
.IP "" 4
.nf
foo = "bar
.fi
.IP "" 0
.P
will always determine the same behavior as if it were
.IP "" 4
.nf
foo = "bar"
.fi
.IP "" 0
.P
Any format containing the following three settings will never produce \fBINI_UNKNOWN\fR nodes, even if instead of an INI file we tried to parse a \fB\.jpeg\fR image (or anything else):
.IP "" 4
.nf
IniFormat my_format = {
  \.delimiter_symbol = INI_ANY_SPACE,
  \.section_paths = INI_NO_SECTIONS,
  \.no_spaces_in_names = false,
  \|\.\|\.\|\.
};
.fi
.IP "" 0
.SS "PERFORMANCE"
The algorithms used by \fBlibconfini\fR stand in a delicate equilibrium between flexibility, speed and code readability, with flexibility as primary target\. Performance can vary with the format used to parse an INI file, but in most cases is not a concern\.
.P
One can measure the performance of the library by doing something like:
.IP "" 4
.nf
/*  dev/tests/performance/performance\.c  */

#include <stdio\.h>
#include <confini\.h>
#include <time\.h>

static int get_ini_size (IniStatistics * stats, void * v_bytes) {

  *((size_t *) v_bytes) = stats\->bytes;
  return 0;

}

static int empty_listener (IniDispatch * dispatch, void * v_bytes) {

  return 0;

}

int main () {

  size_t bytes;
  double seconds;

  clock_t start, end;
  start = clock();

  /*  Please create an INI file large enough  */
  if (load_ini_path(
    "big_file\.ini",
    INI_DEFAULT_FORMAT,
    get_ini_size,
    empty_listener,
    &bytes
  )) {

    return 1;

  }

  end = clock();
  seconds = (double) (end \- start) / CLOCKS_PER_SEC;

  printf(
    "%zu bytes parsed in %f seconds\.\en"
    "Number of bytes parsed per second: %f\en",
    bytes, seconds, (double) bytes / seconds
  );

  return 0;

}
.fi
.IP "" 0
.P
By changing the format of the INI file on the code above one might obtain different results\. In particular, switching disabled entry recognition off – by setting \fBIniFormat::semicolon_marker\fR and \fBIniFormat::hash_marker\fR to \fBINI_ONLY_COMMENT\fR or \fBINI_IGNORE\fR – and making the format non\-multi\-line – by setting \fBIniFormat::multiline_nodes\fR to \fBINI_NO_MULTILINE\fR – will have a positive impact on the performance\.
.P
On my laptop \fBlibconfini\fR seems to parse around 95 MiB per second using the model format \fBINI_DEFAULT_FORMAT\fR\. Whether this is enough for you or not, it depends only on your needs\.
.IP "" 4
.nf
53411840 bytes (1146880 nodes) parsed in 0\.533315 seconds\.
Number of bytes parsed per second: 100150642\.678342
.fi
.IP "" 0
.P
If you are interested in testing yourself the library\'s performance on a particular hardware, you can find a performance test under \fBdev/tests/performance\fR\.
.SH "INI SYNTAX CONSIDERATIONS"
.SS "COMMENT OR DISABLED ENTRY?"
It is hard to imagine a reason to be interested in disabled entries if not for writing a GUI editor for INI files\. If this is the case and you are not using \fBlibconfini\fR like normal people do, you might wonder how to ensure that disabled entries and comments be always parsed without ambiguity\.
.P
In most of the cases \fBlibconfini\fR is smart enough to distinguish a disabled entry from a comment\. However some INI files can be tricky and might require some workarounds\. For instance, imagine the following INI file:
.IP "" 4
.nf
# INI KEY/VALUE DELIMITER: `=`

[some_section]

hello = world

;foo = bar

##now=Sunday April 3rd, 2016
.fi
.IP "" 0
.P
And imagine that for unknown reasons the author of the INI file wanted only \fB;foo = bar\fR to be considered as a disabled entry, and the first and last line as normal comments\.
.P
If we tried to parse it according to the format used below
.IP "" 4
.nf
#include <stdio\.h>
#include <confini\.h>

static int ini_listener (IniDispatch * dispatch, void * v_null) {

  printf(
    "Node #%zu \- Type: %u; Data: \e"%s\e"; Value: \e"%s\e"\en",
    dispatch\->dispatch_id,
    dispatch\->type,
    dispatch\->data,
    dispatch\->value
  );

  return 0;

}

int main () {

  #define MY_FORMAT \e
    ((IniFormat) { \e
      \.delimiter_symbol = INI_EQUALS, \e
      \.case_sensitive = false, \e
      \.semicolon_marker = INI_DISABLED_OR_COMMENT, \e
      \.hash_marker = INI_DISABLED_OR_COMMENT, \e
      \.multiline_nodes = INI_NO_MULTILINE, \e
      \.section_paths = INI_ABSOLUTE_ONLY, \e
      \.no_single_quotes = false, \e
      \.no_double_quotes = false, \e
      \.no_spaces_in_names = false, \e
      \.implicit_is_not_empty = true, \e
      \.do_not_collapse_values = false, \e
      \.preserve_empty_quotes = false, \e
      \.disabled_after_space = true, \e
      \.disabled_can_be_implicit = true \e
    })

  printf(":: Content of \e"ambiguous\.conf\e" ::\en\en");

  if (load_ini_path(
    "\.\./ini_files/ambiguous\.conf",
    MY_FORMAT,
    NULL,
    ini_listener,
    NULL
  )) {

    fprintf(stderr, "Sorry, something went wrong :\-(\en");
    return 1;

  }

  return 0;

}
.fi
.IP "" 0
.P
we would obtain the following result:
.IP "" 4
.nf
:: Content of "ambiguous\.conf" ::

Node #0 \- Type: 6; Data: "INI KEY/VALUE DELIMITER: `"; Value: "`"
Node #1 \- Type: 3; Data: "some_section"; Value: ""
Node #2 \- Type: 2; Data: "hello"; Value: "world"
Node #3 \- Type: 6; Data: "foo"; Value: "bar"
Node #4 \- Type: 4; Data: "now=Sunday April 3rd, 2016"; Value: ""
.fi
.IP "" 0
.P
As you can see, all comments but \fBnow=Sunday April 3rd, 2016\fR would be parsed as disabled entries – which is not what the author intended\. Therefore, to ensure that such INI file be parsed properly, you can follow two possible approaches\.
.P
\fB1\. Intervene on the INI file\.\fR The reason why \fBnow=Sunday April 3rd, 2016\fR has been properly parsed as a comment – despite it really looks like a disabled entry – is because it has been nested within a comment block opened by more than one leading marker (in this case the two \fB#\fR)\. As a general rule, \fI\fBlibconfini\fR never parses a comment beginning with more than one leading marker as a disabled entry\fR, therefore this is the surest way to ensure that proper comments are always considered as such\.
.P
Hence, by adding one more number sign to the first comment
.IP "" 4
.nf
## INI KEY/VALUE DELIMITER: `=`

[some_section]

hello = world

;foo = bar

##now=Sunday April 3rd, 2016
.fi
.IP "" 0
.P
we obtain the wanted result:
.IP "" 4
.nf
:: Content of "ambiguous\.conf" ::

Node #0 \- Type: 4; Data: " INI KEY/VALUE DELIMITER: `=`"; Value: ""
Node #1 \- Type: 3; Data: "some_section"; Value: ""
Node #2 \- Type: 2; Data: "hello"; Value: "world"
Node #3 \- Type: 6; Data: "foo"; Value: "bar"
Node #4 \- Type: 4; Data: "now=Sunday April 3rd, 2016"; Value: ""
.fi
.IP "" 0
.P
\fB2\. Intervene on the format\.\fR There are cases where the INI file is automatically generated by machines (comments included), or distributed as such, and human intervention would be required on each machine\-generated release of the INI file\. In these cases – and if we are sure about the expected content of the INI file – we can restrict the format chosen in order to parse comments and disabled entries properly\. In particular, the following fields of the \fBIniFormat\fR bitfield can have an impact on the disambiguation between comments and disabled entries\.
.P
Reliable general patterns:
.IP "\[ci]" 4
\fBIniFormat::semicolon_marker\fR and \fBIniFormat::hash_marker\fR – The imaginary author of our INI file, if we observe the latter closer, chose the semicolon symbol as the marker of disabled entries and the hash symbol as the marker of comments\. We may exploit this difference and set our \fBmy_format\.semicolon_marker\fR to \fBINI_DISABLED_OR_COMMENT\fR and our \fBmy_format\.hash_marker\fR to \fBINI_ONLY_COMMENT\fR to obtain the correct disambiguation\. If you believe that this solution is too artificial, think that \fB/etc/samba/smb\.conf\fR and \fB/etc/pulse/daemon\.conf\fR are systematically distributed using this pattern\.
.IP "\[ci]" 4
\fBIniFormat::disabled_after_space\fR – Setting this property to \fBfalse\fR, due to the initial space that follows the comment marker (\fB# INI\|\.\|\.\|\.\fR), forces the entire line to be considered as a comment\. Some authors use this syntax to distinguish between comments and disabled entries (examples are \fB/etc/pacman\.conf\fR and \fB/etc/bluetooth/main\.conf\fR)
.IP "" 0
.P
Temporary workarounds:
.IP "\[ci]" 4
\fBIniFormat::no_spaces_in_names\fR – If our INI file has only comments containing more than one word and we are sure that key and section names cannot contain internal white spaces, we can set this property to \fBtrue\fR to enhance disambiguation\.
.IP "\[ci]" 4
\fBIniFormat::disabled_can_be_implicit\fR – This property, if set to \fBfalse\fR, forces all comments that do not contain a key\-value delimiter never to be considered as disabled entries\. Despite not having an impact on our example, it has an impact on the disambiguation algorithms used by \fBlibconfini\fR\. Its value in \fBINI_DEFAULT_FORMAT\fR is set to \fBfalse\fR\.
.IP "" 0
.P
As a general rule, \fBlibconfini\fR will always try to parse as a disabled entry whatever comment is allowed (by the format) to contain one\. Only if this attempt fails, the block will be dispatched as a normal comment\.
